package WaiBao;

import java.util.Arrays;

public class WangLiangLiang {
    public static void main(String[] args) {
        String[] name = {"王大夫(班长)", "李可(副班长)", "李大(组织委员)", "王超(体育委员)", "张伟", "增小仙", "王小胖", "李号", "王志阳", "小帅", "韩星", "裴东来",
                "鲍指向", "李迅", "李晓华", "代正", "戴天理", "李白", "肖战", "林摇动", "陈奕迅", "白芝麻", "黄先", "马化腾", "马云", "王星", "雷军", "淑华",
                "王一博", "王亮亮(学生)"};//考生本人:王亮亮(学生)
        int[] age = {20, 21, 20, 18, 19, 18, 118, 21, 18, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 21, 20};
        double[] a1 = {78, 82, 84, 90, 88, 69, 78, 89, 80, 90, 90, 67, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 74, 81, 92};
        double[] a2 = {79, 85, 79, 66, 68, 67, 88, 99, 90, 90, 90, 67, 66, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 84, 74, 64, 94, 93};
        double[] a3 = {88, 86, 80, 95, 79, 99, 68, 89, 80, 60, 93, 87, 85, 65, 65, 68, 89, 69, 96, 93, 92, 81, 95, 85, 76, 84, 73, 71, 88, 94};

        double Sum1;//代表每个学生的总分
        double average;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            Sum1 = a1[i] + a2[i] +a3[i];
//            average = (Sum1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + Sum1);
//            System.out.println(name[i] + "的平均分为:" +average);
//        }

        double Result = 0, Average = 0;
        double[] arr = new double[30];
//        for (int i = 0; i < 30; i++) {
//            Result = a1[i] + a2[i] + a3[i];
//            average = (Result * 1.0) / 3;
//            arr[i] = average;
//        }
//
//        for (int i = 0; i < arr.length - 1; i++) {
//            for (int j = 0; j < arr.length - i - 1; j++) {
//                if (arr[j] < arr[j + 1]) {
//                    double tep = arr[j];
//                    arr[j] = arr[j + 1];
//                    arr[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(arr[i]);
//        }


        double d1 = 0, d2 = 0, d3 = 0;//计算每门课的平均分
        double h1 = 0, h2 = 0, h3 = 0;//计算每门课标准差
        double m1 = 0, m2 = 0, m3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < a1.length; i++) {
            sum2+=a1[i];
        }
        d1 = (sum2*1.0)/30;
        System.out.println("农业设施及环境调控的班级平均分为:"+d1);
        double Sum = 0;
        for (int i = 0; i < a2.length; i++) {
            Sum+=a2[i];
        }
        d2 = (Sum*1.0)/30;
        System.out.println("农业设施设计与建造的班级平均分为:"+d2);
        double sum = 0;
        for (int i = 0; i <a3.length; i++) {
            sum+=a3[i];
        }
        d3 = (sum*1.0)/30;
        System.out.println("园艺植物设施栽培学的班级平均分为:"+d3);

        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < a1.length; i++) {
            c1+= (a1[i] - d1)*(a1[i] - d1);
        }
        h1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:"+h1);

        for (int i = 0; i < a2.length; i++) {
            c2+= (a2[i] - d2)*(a2[i] - d2);
        }
        h2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:"+h2);

        for (int i = 0; i < a3.length; i++) {
            c3+= (a3[i] - d3)*(a3[i] - d3);
        }
        h3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的班级标准差为:"+h3);
//
//        Arrays.sort(a1);
//        Arrays.sort(a2);
//        Arrays.sort(a3);
//        m1 =( a1[15]+a1[16])*1.0/2;
//        m2 =( a2[15]+a2[16])*1.0/2;
//        m3 =( a3[15]+a3[16])*1.0/2;
//        System.out.println("农业设施及环境调控的中位数为:"+m1);
//        System.out.println("业设施设计与建造的中位数为:"+m2);
//        System.out.println("园艺植物设施栽培学的中位数为:"+m3);
    }
}
